/*
 * TraceValue.c
 *
 *  Created on: 2012/07/06
 *      Author: guanxiaoying
 */
#include <float.h>
#include "../tracedef.h"
#include "trace_cmd.h"

/*TODO: !!!NOTICE: about  S8 U8,  the significant digit of type DOUBLE is not enough to
        save maximum value of S8 or U8 */
#define GET_INTEGER(type, db)  ((type)((db)>=0?((db)+0.5):((db)-0.5)))

static VOID tr_ValueCorrectFloatingError( TRVALUE *stResult ){
	if( !stResult->bFloating ){
		if( stResult->dbValue >= 0 ){
			stResult->dbValue = GET_INTEGER(U8, stResult->dbValue);
		}else{
			stResult->dbValue = GET_INTEGER(S8, stResult->dbValue);
		}
	}
}
/* -v */
VOID Tr_ValueMinus( TRVALUE *stValue1, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	*stResult = *stValue1;
	stResult->dbValue = -stResult->dbValue;
}
/* get absolute value */
VOID Tr_ValueAbs( TRVALUE *stValue1, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	*stResult = *stValue1;
	if( stResult->dbValue < 0 ){
		stResult->dbValue = -stResult->dbValue;
	}
}
/* return true if the value is negative */
BOOL Tr_ValueIsNegative( TRVALUE *stResult )
{
	assert( stResult != NULL );
	if( stResult->ucValueFlag == TRVALUE_NORMAL && stResult->dbValue < 0 ){
		return TRUE;
	}
	return FALSE;
}
/* return true if the value is positive */
BOOL Tr_ValueIsPositive( TRVALUE *stResult )
{
	assert( stResult != NULL );
	if( stResult->ucValueFlag == TRVALUE_NORMAL && stResult->dbValue > 0 ){
		return TRUE;
	}
	return FALSE;
}
/* return true if the value is 0 */
BOOL Tr_ValueIsZero( TRVALUE *stResult )
{
	assert( stResult != NULL );
	if( stResult->ucValueFlag == TRVALUE_NORMAL && stResult->dbValue == 0 ){
		return TRUE;
	}
	return FALSE;
}
/* return true if the value is floating */
BOOL Tr_ValueIsFloating( TRVALUE *stResult )
{
	assert( stResult != NULL );
	return stResult->bFloating;
}
/* A++*/
VOID Tr_ValueInc( TRVALUE *stValue1, TRVALUE *stResult )
{
	TRVALUE one ;
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	Tr_ValueNewOne( &one, stValue1->bFloating );
	Tr_ValueAdd( stValue1, &one, stResult );
}
/* A--*/
VOID Tr_ValueDec( TRVALUE *stValue1, TRVALUE *stResult )
{
	TRVALUE one ;
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	Tr_ValueNewOne( &one, stValue1->bFloating );
	Tr_ValueSub( stValue1, &one, stResult );
}
/* A+B */
VOID Tr_ValueAdd( TRVALUE *stValue1, TRVALUE *stValue2, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	assert( stValue2 != NULL );

	if( stValue1->bFloating || stValue2->bFloating ){
		stResult->bFloating = TRUE;
	}else{
		stResult->bFloating = FALSE;
		tr_ValueCorrectFloatingError( stValue1 );
		tr_ValueCorrectFloatingError( stValue2 );
	}
	stResult->dbValue = stValue1->dbValue + stValue2->dbValue;
	if( !IS_FINITE( stResult->dbValue)){
		stResult->ucValueFlag = TRVALUE_INF;
	}else{
		stResult->ucValueFlag = TRVALUE_NORMAL;
	}
}
/* A-B */
VOID Tr_ValueSub( TRVALUE *stValue1, TRVALUE *stValue2, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	assert( stValue2 != NULL );
	if( stValue1->bFloating || stValue2->bFloating ){
		stResult->bFloating = TRUE;
	}else{
		stResult->bFloating = FALSE;
		tr_ValueCorrectFloatingError( stValue1 );
		tr_ValueCorrectFloatingError( stValue2 );
	}
	stResult->dbValue = stValue1->dbValue - stValue2->dbValue;
	if( !IS_FINITE( stResult->dbValue)){
		stResult->ucValueFlag = TRVALUE_INF;
	}else{
		stResult->ucValueFlag = TRVALUE_NORMAL;
	}
}
/* A*B */
VOID Tr_ValueMul( TRVALUE *stValue1, TRVALUE *stValue2, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	assert( stValue2 != NULL );

	if( stValue1->bFloating || stValue2->bFloating ){
		stResult->bFloating = TRUE;
	}else{
		stResult->bFloating = FALSE;
		tr_ValueCorrectFloatingError( stValue1 );
		tr_ValueCorrectFloatingError( stValue2 );
	}
	stResult->dbValue = stValue1->dbValue * stValue2->dbValue;
	if( !IS_FINITE( stResult->dbValue)){
		stResult->ucValueFlag = TRVALUE_INF;
	}else{
		stResult->ucValueFlag = TRVALUE_NORMAL;
	}
}
/* A/B */
VOID Tr_ValueDiv( TRVALUE *stValue1, TRVALUE *stValue2, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	assert( stValue2 != NULL );

	if( stValue1->bFloating || stValue2->bFloating ){
		stResult->bFloating = TRUE;
	}else{
		stResult->bFloating = FALSE;
		tr_ValueCorrectFloatingError(stValue1);
		tr_ValueCorrectFloatingError(stValue2);
	}
	if( stValue2->dbValue == 0 ){
		stResult->dbValue = stValue1->dbValue;
		stResult->ucValueFlag = TRVALUE_INF;
	}else{
		if(stResult->bFloating){
			stResult->dbValue = stValue1->dbValue / stValue2->dbValue;
			if( !IS_FINITE( stResult->dbValue)){
				stResult->ucValueFlag = TRVALUE_INF;
			}else{
				stResult->ucValueFlag = TRVALUE_NORMAL;
			}
		}else{
			TRVALUE abs1;
			TRVALUE abs2;
			Tr_ValueAbs( stValue1, &abs1 );
			Tr_ValueAbs( stValue2, &abs2 );
			stResult->dbValue = GET_INTEGER( U8, abs1.dbValue )/GET_INTEGER( U8, abs2.dbValue );
			if( abs2.dbValue * stResult->dbValue + 0.5 < abs1.dbValue ){
				/* there is remainder */
				if( abs1.dbValue > 0 && abs2.dbValue < 0 ){
					if( stCoreEnvInfo.ucModuloSign == OPT_MODULO_SIGNED ){
						stResult->dbValue++;
						stResult->dbValue = -stResult->dbValue;
					}
				}else if( abs1.dbValue < 0 && abs2.dbValue < 0 ){
					if (stCoreEnvInfo.ucModuloSign == OPT_MODULO_UNSIGNED ){
						stResult->dbValue++;
					}
				}else if( abs1.dbValue < 0 && abs2.dbValue > 0 ){
					if (stCoreEnvInfo.ucModuloSign == OPT_MODULO_UNSIGNED ){
						stResult->dbValue++;
						stResult->dbValue = -stResult->dbValue;
					}
				}
			}else{
				/* no remainder */
			}
		}
	}
}
/* A%B */
VOID Tr_ValueMod( TRVALUE *stValue1, TRVALUE *stValue2, TRVALUE *stResult )
{
	assert( stResult != NULL );
	assert( stValue1 != NULL );
	assert( stValue2 != NULL );
	assert( stValue1->bFloating == FALSE );
	assert( stValue2->bFloating == FALSE );
	if( stValue1->bFloating || stValue2->bFloating ){
		stResult->dbValue = stValue1->dbValue;
		stResult->ucValueFlag = TRVALUE_INF;
	}else{
		stResult->bFloating = FALSE;
		stResult->ucValueFlag = TRVALUE_NORMAL;
		tr_ValueCorrectFloatingError(stValue1);
		tr_ValueCorrectFloatingError(stValue2);
		if( stValue2->dbValue  == 0 ){
			stResult->dbValue = stValue1->dbValue;
			stResult->ucValueFlag = TRVALUE_INF;
		}else if( stValue1->dbValue  == 0 ){
			stResult->dbValue = 0;
		}else{
			TRVALUE abs1;
			TRVALUE abs2;
			Tr_ValueAbs( stValue1, &abs1 );
			Tr_ValueAbs( stValue2, &abs2 );
			stResult->dbValue = GET_INTEGER( U8, abs1.dbValue )%GET_INTEGER( U8, abs2.dbValue );
			if( stValue1->dbValue > 0 && stValue2->dbValue < 0 ){
				if( stCoreEnvInfo.ucModuloSign == OPT_MODULO_SIGNED ){
					stResult->dbValue = abs2.dbValue - stResult->dbValue;
					stResult->dbValue = -stResult->dbValue ;
				}
			}else if( stValue1->dbValue < 0 && stValue2->dbValue < 0 ){
				if (stCoreEnvInfo.ucModuloSign == OPT_MODULO_UNSIGNED ){
					stResult->dbValue = abs2.dbValue - stResult->dbValue;
				}
			}else if( stValue1->dbValue < 0 && stValue2->dbValue > 0 ){
				if (stCoreEnvInfo.ucModuloSign == OPT_MODULO_UNSIGNED ){
					stResult->dbValue = abs2.dbValue - stResult->dbValue;
				}
			}
			tr_ValueCorrectFloatingError(stResult);
		}
	}
}
/* create a 0 value
 * bFloating = TRUE floating 0.
 * bFloating = FALSE integer 0.
 * */
VOID Tr_ValueNewZero( TRVALUE *stResult, BOOL bFloating )
{
	assert( stResult != NULL );
	stResult->bFloating = bFloating;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = 0;
}
/* create a 1 value
 * bFloating = TRUE floating 1.
 * bFloating = FALSE integer 1.
 * */
VOID Tr_ValueNewOne( TRVALUE *stResult, BOOL bFloating )
{
	assert( stResult != NULL );
	stResult->bFloating = bFloating;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = 1.;
}
/* create maximum value of type S1
 * */
VOID Tr_ValueNewS1Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = FALSE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = (DOUBLE)127;
}
/* create minimum value of type S1
 * */
VOID Tr_ValueNewS1Min( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = FALSE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = (DOUBLE)-128;
}
/* create maximum value of type S2
 * */
VOID Tr_ValueNewS2Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS1Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue * 2;
	stResult->dbValue -= 1;
}
/* create minimum value of type S2
 * */
VOID Tr_ValueNewS2Min( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS1Min(stResult);
	stResult->dbValue = -stResult->dbValue * stResult->dbValue * 2;
}
/* create maximum value of type S4
 * */
VOID Tr_ValueNewS4Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS2Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue * 2;
	stResult->dbValue -= 1;
}
/* create minimum value of type S4
 * */
VOID Tr_ValueNewS4Min( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS2Min(stResult);
	stResult->dbValue = -stResult->dbValue * stResult->dbValue * 2;
}
/* create maximum value of type S8
 * */
VOID Tr_ValueNewS8Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS4Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue * 2;
	stResult->dbValue -= 1;
}
/* create minimum value of type S8
 * */
VOID Tr_ValueNewS8Min( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewS4Min(stResult);
	stResult->dbValue = -stResult->dbValue * stResult->dbValue * 2;
}
/* create maximum value of type U1
 * */
VOID Tr_ValueNewU1Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = FALSE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = (DOUBLE)255;
}
/* create maximum value of type U2
 * */
VOID Tr_ValueNewU2Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewU1Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue;
	stResult->dbValue -= 1;
}
/* create maximum value of type U4
 * */
VOID Tr_ValueNewU4Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewU2Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue;
	stResult->dbValue -= 1;
}
/* create maximum value of type U8
 * */
VOID Tr_ValueNewU8Max( TRVALUE *stResult )
{
	assert( stResult != NULL );
	Tr_ValueNewU4Max(stResult);
	stResult->dbValue += 1;
	stResult->dbValue = stResult->dbValue * stResult->dbValue;
	stResult->dbValue -= 1;
}
/* create minimum value of type double
 * */
VOID Tr_ValueNewDoubleMin( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = TRUE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = -DBL_MAX;
}
/* create maximum value of type double
 * */
VOID Tr_ValueNewDoubleMax( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = TRUE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = DBL_MAX;
}
/* create minimum value of type float
 * */
VOID Tr_ValueNewFloatMin( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = TRUE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = -FLT_MAX;
}
/* create maximum value of type float
 * */
VOID Tr_ValueNewFloatMax( TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = TRUE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = FLT_MAX;
}
/* create floating value from a double value
 * */
VOID Tr_ValueNewFloating( DOUBLE floating, TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = TRUE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = floating;
}
/* create integer value from a integer value in core
 * */
VOID Tr_ValueNewInteger( INTVALUE value, TRVALUE *stResult )
{
	assert( stResult != NULL );
	stResult->bFloating = FALSE;
	stResult->ucValueFlag = TRVALUE_NORMAL;
	stResult->dbValue = value.u8Remainder;
	if( value.sign < 0 ){
		stResult->dbValue = -stResult->dbValue;
	}
}
/* whether the value is valid */
/*debug,12/10/23,S*/
BOOL DLL_EXPORT Tr_ValueIsNormal( TRVALUE *stResult )
/*debug,12/10/23,E*/
{
	assert( stResult != NULL );
	if( stResult->ucValueFlag != TRVALUE_NORMAL ){
		return FALSE;
	}
	if( !IS_FINITE( stResult->dbValue ) ){
		return FALSE;
	}
	return TRUE;
}
/* whether st1 is less than st2 */
/*debug,12/10/23,S*/
BOOL DLL_EXPORT Tr_ValueLessThan( TRVALUE *st1, TRVALUE *st2 )
/*debug,12/10/23,E*/
{
	TRVALUE stCmpValue;
	assert( st1 != NULL );
	assert( st2 != NULL );
	Tr_ValueSub( st1, st2, &stCmpValue );
	if( Tr_ValueIsNegative( &stCmpValue ) ){
		return TRUE;
	}
	return FALSE;
}
/* whether st1 is not more than st2 */
/*debug,12/10/23,S*/
BOOL DLL_EXPORT Tr_ValueLessOrEqual( TRVALUE *st1, TRVALUE *st2 )
/*debug,12/10/23,E*/
{
	return Tr_ValueLessThan( st1, st2 ) || Tr_ValueEqual( st1, st2 );
}
/* whether st1 is equal to st2 */
/*debug,12/10/23,S*/
BOOL DLL_EXPORT Tr_ValueEqual( TRVALUE *st1, TRVALUE *st2 )
/*debug,12/10/23,E*/
{
	TRVALUE stCmpValue;
	assert( st1 != NULL );
	assert( st2 != NULL );
	Tr_ValueSub( st1, st2, &stCmpValue );
	if( Tr_ValueIsZero( &stCmpValue ) ){
		return TRUE;
	}
	return FALSE;
}
VOID Tr_ValueAdjust2Bit( TRVALUE *st1, U2 size, BOOL sign ){
	if( st1->bFloating ){

		DOUBLE max;
		DOUBLE min;
		st1->bFloating = FALSE;
		if( sign ){
			if( size == 1 ){
				min = -1;
				max = 0;
			}else if( size < sizeof( S8 ) * CHARBIT ){
				S8 mask = 1;
				U2 cnt = size;
				while( cnt > 2 ){
					mask <<= 1;
					mask += 1;
					cnt--;
				}
				min = mask + 1;
				min *= -1;
				max = mask;
			}
		}else{
			//unsigned
			U8 mask = 1;
			U2 cnt = size;
			while( cnt > 1 ){
				mask <<= 1;
				mask += 1;
				cnt--;
			}
			min = 0;
			max = mask;
		}
		if( st1->dbValue > max || st1->dbValue < min ){
			st1->ucValueFlag = TRVALUE_INF;
		}else{
			if( sign ){
				st1->dbValue = (S8)st1->dbValue;
			}else{
				st1->dbValue = (U8)st1->dbValue;
			}
		}
		return;
	}
	if( size > 0 ){
		if( sign ){
			if( size == 1 ){
				S8 value = (S8)st1->dbValue;
				if( value & 0x1 ){
					st1->dbValue = -1;
				}else{
					st1->dbValue = 0;
				}
			}else if( size < sizeof( S8 ) * CHARBIT ){
				S8 mask = 1;
				S8 value = (S8)st1->dbValue;
				U2 cnt = size;
				while( cnt > 2 ){
					mask <<= 1;
					mask += 1;
					cnt--;
				}
				if( value & (1<<(size - 1))){
					// negative
					value = ~value;
					value &= mask;
					value += 1;
					st1->dbValue = -(DOUBLE)value;
				}else{
					// positive
					value &= mask;
					st1->dbValue = (DOUBLE)value;
				}
			}
		}else{
			//unsigned
			if( size == 1 ){
				U8 value = (U8)st1->dbValue;
				if( value & 0x1 ){
					st1->dbValue = 1;
				}else{
					st1->dbValue = 0;
				}
			}else if( size < sizeof( U8 ) * CHARBIT ){
				U8 mask = 1;
				U8 value = (U8)st1->dbValue;
				U2 cnt = size;
				while( cnt > 1 ){
					mask <<= 1;
					mask += 1;
					cnt--;
				}
				value &= mask;
				st1->dbValue = (DOUBLE)value;
			}
		}
	}else{
		st1->dbValue = 0;
	}
}
VOID Tr_ValueAdjust( TRVALUE *st1, U2 size, BOOL sign, BOOL bFloating ){
	TRVALUE max;
	TRVALUE min;
	if( st1->bFloating && bFloating ){
		// floating -> floating
		if( size == FLOATSIZE ){
			Tr_ValueNewFloatMax( &max );
			Tr_ValueNewFloatMin( &min );
			if( Tr_ValueLessThan( &max, st1 ) ){
				st1->ucValueFlag = TRVALUE_INF;
			}else if( Tr_ValueLessThan(  st1, &min ) ){
				st1->ucValueFlag = TRVALUE_INF;
			}
		}else if( size == DOUBLESIZE || size == LONGDOUBLESIZE ){
			//DO nothing
		}else{
			st1->ucValueFlag = TRVALUE_NAN;
		}
	}else if( !st1->bFloating && bFloating ){
		// integer -> floating
		st1->bFloating = TRUE;
	}else if( st1->bFloating && !bFloating ){
		// floating -> integer
		st1->bFloating = FALSE;
		if( sign ){
			if( size == 1 ){
				Tr_ValueNewS1Max( &max );
				Tr_ValueNewS1Min( &min );
			}else if( size == 2 ){
				Tr_ValueNewS2Max( &max );
				Tr_ValueNewS2Min( &min );
			}else if( size == 4 ){
				Tr_ValueNewS4Max( &max );
				Tr_ValueNewS4Min( &min );
			}else{
				Tr_ValueNewS8Max( &max );
				Tr_ValueNewS8Min( &min );
			}
		}else{
			if( size == 1 ){
				Tr_ValueNewU1Max( &max );
			}else if( size == 2 ){
				Tr_ValueNewU2Max( &max );
			}else if( size == 4 ){
				Tr_ValueNewU4Max( &max );
			}else{
				Tr_ValueNewU8Max( &max );
			}
			Tr_ValueNewZero( &min, FALSE );
		}
		if( Tr_ValueLessThan(  st1, &min ) ){
			st1->ucValueFlag = TRVALUE_INF;
		}else if( Tr_ValueLessThan(  &max, st1 ) ){
			st1->ucValueFlag = TRVALUE_INF;
		}else{
			if( sign ){
				st1->dbValue = (S8)st1->dbValue;
			}else{
				st1->dbValue = (U8)st1->dbValue;
			}
		}
	}else{
		// integer -> integer
		st1->bFloating = FALSE;
		if( sign ){
			S8 s8Value = 0;
			if( st1->dbValue > 0 ){
				s8Value = (S8)(U8)st1->dbValue;
				if( s8Value == 0 && st1->dbValue > 1 ){
					/* refer the !NOTICE in front */
					s8Value = 0xFFFFFFFFUL;
					s8Value = s8Value * ( s8Value + 1 );
					s8Value += 0xFFFFFFFFUL;
				}
			}else{
				s8Value = (S8)st1->dbValue;
			}
			if( size == 1 ){
				s8Value = (SCHAR)s8Value;
				st1->dbValue = (DOUBLE)s8Value;
			}else if( size == 2 ){
				s8Value = (S2)s8Value;
				st1->dbValue = (DOUBLE)s8Value;
			}else if( size == 4 ){
				s8Value = (S4)s8Value;
				st1->dbValue = (DOUBLE)s8Value;
			}else{
				st1->dbValue = (DOUBLE)s8Value;
			}
		}else{
			U8 u8Value = 0;
			if( st1->dbValue >= 0 ){
				u8Value = (U8)st1->dbValue;
				/* refer the !NOTICE in front */
				if( u8Value == 0 && st1->dbValue > 1 ){
					u8Value = 0xFFFFFFFFUL;
					u8Value = u8Value * ( u8Value + 1 );
					u8Value += 0xFFFFFFFFUL;
				}
			}else{
				u8Value = (U8)(S8)st1->dbValue;
			}
			if( size == 1 ){
				u8Value = (UCHAR)u8Value;
				st1->dbValue = (DOUBLE)u8Value;
			}else if( size == 2 ){
				u8Value = (U2)u8Value;
				st1->dbValue = (DOUBLE)u8Value;
			}else if( size == 4 ){
				u8Value = (U4)u8Value;
				st1->dbValue = (DOUBLE)u8Value;
			}else{
				st1->dbValue = (DOUBLE)u8Value;
			}
		}
	}
}
